package third;

import java.util.Scanner;

public class third_15 {
    public static void main(String[] args) {

		int lottery = (int)(Math.random() * 1000);

		Scanner input = new Scanner(System.in);
		System.out.print("Enter your lottery pick (Three digits): ");
		int guess = input.nextInt();
		int lg3=lottery%10;
		int lg2=(lottery/10)%10;
		int lg1=lottery/100;
		int gs3=guess%10;
		int gs2=(guess/10)%10;
		int gs1=guess/100;
		System.out.println("The lottery number is " + lottery);

		int[] bl = new int[10];
		for(int i=0;i<10;i++) {
			bl[i]=0;
		}
		bl[lg1]+=1;
		bl[lg2]+=1;
		bl[lg3]+=1;

		if(guess == lottery) {
			System.out.println("Exact match:you win $10000");
		}else if(bl[gs1]>0||bl[gs2]>0||bl[gs3]>0) {
			bl[gs1]-=1;
			bl[gs2]-=1;
			bl[gs3]-=1;
			if(bl[lg1]>0||bl[lg2]>0||bl[lg3]>0) {
				System.out.println("Match one or two digits: you win $1000");
			}else {
				System.out.println("Match all digits: you win $3000");
			}
		}else {
			System.out.println("Sorry, no match");
		}
    }
}
